﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using Ingebet.Model.Domain;
using NHibernate;
using NHibernate.Cfg;

namespace Ingebet
{
    public class HelperSessionFactory
    {
        private static ISessionFactory sessionFactory;

        private static void Init()
        {
            var config = new Configuration().AddAssembly(Assembly.GetAssembly(typeof(Utilisateur)));

            sessionFactory = config.BuildSessionFactory();
        }

        public static ISession GetCurrentSession()
        {
            if (sessionFactory == null)
                Init();

            return sessionFactory.OpenSession();
        }
    }
}